package com.basic.java.scanPackage.service;


import com.basic.java.scanPackage.dao.ScanDao;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Controller;
import org.springframework.stereotype.Repository;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 类
 * 创建时间：2022/3/9 20:51
 *
 * @author gejin
 */
// 注解中的value 可以不写， 默认是创建类的首字母小写
//@Component(value = "userService")  // <bean id="userService" class ="">
//@Service
//@Controller
@Service
public class UserService {
    @Value(value = "abc") // 注入普通类型
    private String name;
    /*
    @Autowired // 根据类型进行注入
    private ScanDao scanDao;
    */

    /*
    //  @Qualifier 需要配合 @Autowired使用
    @Autowired
    @Qualifier(value = "testScanDaoImpl") // 根据名称进行注入
    private ScanDao scanDao;
    */
    // @Resource  // 根据类型注入
    @Resource(name = "testScanDaoImpl")  // 根据名称进行zhur
    private ScanDao scanDao;

    public void test() {
        System.out.println("Service add ...");
        scanDao.add();

    }

    @Override
    public String toString() {
        return "UserService{" +
                "name='" + name + '\'' +
                ", scanDao=" + scanDao +
                '}';
    }
}
